<?php

!defined('IN_VIFRAME') && die('Access Denied.');

abstract class TClass {
	
	protected
		$_LastParam = array();
		
	protected
		$_Configs   = array();
	
	protected function _filterParam($key, $param, $default = 0) {
		if (!isset($this->_LastParam[$key])) {
			$this->_LastParam[$key] = false;
		}
		
		$lastParam = & $this->_LastParam[$key];
		
		if (false === $param){
			if (false === $lastParam) {
				$param = $lastParam = $default;
			} else {
				$param = $lastParam;
			}
		} else {
			$lastParam = $param;
		}
		
		return $param;
	}
	
	protected function _filterConfigParam($config, $default) {
		return $config + $default;
	}
	
	public function getConfig($key) {
		return (isset($this->_Configs[$key]) ? $this->_Configs[$key] : false);
	}
	
	public function getAllConfigs() {
		return $this->_Configs;
	}
	
	public function setConfig($key, $value = null) {
		if (is_array($key)) {
			$this->_Configs = $key + $this->_Configs;
		} else {
			$this->_Configs[$key] = $value;
		}
		
		return true;
	}
	
	public function removeConfig($key) {
		unset($this->_Configs[$key]);
		
		return true;
	}
	
	public function removeAllConfigs() {
		$this->_Configs = array();
		
		return true;
	}
}